export default{ 
    namespaced: true,
    state:{
        Room:{
            BetHistory:"0,0,0,0,0,0,0,0",
            BetMode:0,
            ChipsSum:"0/0,0/0,0/0,0/0,0/0",
            CurrJu:0,
            CurrState:0,
            CurrXue:0,
            DjsTime:0,
            GType:0,
            G_Result:"",
            HallNumber:0,
            LuDan:"",
            MoneyMax:0,
            MoneyMin:0,
            PaiMian:'',
            PlayerNum:0,
            RestHops:0,
            RoomName:"",
            Room_attribute:0,
            TId:0,
            VideoUrl:"",
            WinLose:0,
            BetStatus:false,
        },
        succenBet:false,
        errorBet:false
    },
    getters:{
        room(state){
            return state.Room;
        },
        succenBet(state){
            return state.succenBet;
        },
        errorBet(state){
            return state.errorBet;
        }
    },
    mutations:{
        // 初始化房间数据
        InitRoom(state){
            state.Room={
                BetHistory:"0,0,0,0,0,0,0,0",
                BetMode:0,
                ChipsSum:"0/0,0/0,0/0,0/0,0/0",
                CurrJu:0,
                CurrState:0,
                CurrXue:0,
                DjsTime:0,
                GType:0,
                G_Result:"",
                HallNumber:0,
                LuDan:"",
                MoneyMax:0,
                MoneyMin:0,
                PaiMian:'',
                PlayerNum:0,
                RestHops:null,
                RoomName:"",
                Room_attribute:0,
                TId:0,
                VideoUrl:"",
                WinLose:0,
            };
        },
        //进入房间处理数据
        setRoomInit(state,msg){
            for(let i in msg){
                if(i!="Balance")
                msg[i]!=state.Room[i]?state.Room[i]=msg[i]:false;
            }
        },
        // 减少时间
        setTime(state){
            if(state.Room.RestHops>0){
                state.Room.RestHops--;
            }
        },
        // 开奖
        openRule(state,msg){
            for(let i in msg){
                if(i!="Balance"){
                    state.Room[i]!=msg[i]?state.Room[i]=msg[i]:false;
                }
            }
            state.Room.CurrState=4;
        },
        // 开局返回
        openNewGame(state,msg){
            // console.log(msg)
            for(let i in msg){
                state.Room[i]!=msg[i]?state.Room[i]=msg[i]:false
            }

            state.Room.PaiMian="";
            state.Room.WinLose=0;
            state.G_Result="";
            state.Room.CurrState=2;
            state.Room.BetHistory="0,0,0,0,0,0,0,0"
        },
        // 设置下注状态
        setBetStatus(state,msg){
            state.BetStatus=msg;
        },
        // 下注成功返回处理
		getBetInfo(state,Msg){
            this.commit("setBalance",Msg.Content.Balance);
			state.Room.CurrJu!=Msg.Content.CurrJu?state.Room.CurrJu=Msg.Content.CurrJu:false;//改变房间鞋局
            state.Room.CurrXue!=Msg.Content.CurrXue?state.Room.CurrJu=Msg.Content.CurrXue:false;//改变房间局
            state.succenBet=Msg.Content.BetInfo;
            state.Room.BetHistory=Msg.Content.BetHistory;
		},
		// 下注失败回调
		setBetInLoser(state){
			state.errorBet=true;
        },
        // 初始化BET公共
        initBteNotice(state){
            state.succenBet=false;
            state.errorBet=false;
        },
        // 下注人数信息更新
        setUserAll(state,Msg){
            // 进行数据写入
			state.Room.ChipsSum!=Msg.ChipsSum?state.Room.ChipsSum=Msg.ChipsSum:false;
			state.Room.OnlineNum!=Msg.OnlineNum?state.Room.OnlineNum=Msg.OnlineNum:false;
        },
        // 停止下注
        setStop(state,Msg){
            let i;
			for(i in Msg.Content){
				state.Room[i]!=Msg.Content[i]?state.Room[i]=Msg.Content[i]:false;
			}
        },
        // 本局作废
        clearGmae(state,Msg){
                state.Room.CurrState=7;
				state.Room.OnlineNum!=Msg.OnlineNum?state.Room.OnlineNum=Msg.OnlineNum:false;
				state.Room.CurrJu!=Msg.Content.CurrJu?state.Room.CurrJu=Msg.Content.CurrJu:false;
				state.Room.CurrXue!=Msg.Content.CurrXue?state.Room.CurrXue=Msg.Content.CurrXue:false;
				state.Room.RestHops=0;
				state.Room.ChipsSum="0/0,0/0,0/0,0/0,0/0";
				state.Room.BetHistory="0,0,0,0,0,0,0,0";
				state.Room.G_Result="";
				state.Room.PaiMian="";
				state.Room.WinLose=0;
        }
    },
    actions:{}
}
